package org.paradise.dms.web.action.aptview;

import java.util.ArrayList;
import java.util.List;

import net.sf.json.JSONArray;

import org.apache.log4j.Logger;
import org.directwebremoting.annotations.RemoteProxy;
import org.paradise.dms.services.StudentService;
import org.paradise.dms.web.action.DMSBaseAction;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 
 * Description: 查询入住宿舍的学生信息
 * 
 * Copyright (c) 2008-2009 paraDise sTudio(DT). All Rights Reserved.
 * 
 * @version 1.0 2009-3-18 下午11:25:52 李双江（paradise.lsj@gmail.com）created
 */
@Service
@RemoteProxy(name = "studentInDormitoryInfoViewAction")
public class StudentInDormitoryInfoViewAction extends DMSBaseAction {
	@SuppressWarnings("unused")
	private static Logger log = Logger.getLogger(StudentInDormitoryInfoViewAction.class);
	/**
	 * 
	 */
	private static final long serialVersionUID = 3768372203099211197L;
	@Autowired
	private StudentService studentService;

	public StudentService getStudentService() {
		return studentService;
	}

	public void setStudentService(StudentService studentService) {
		this.studentService = studentService;
	}

	/**
	 * 
	 * Description: 根据宿舍的id列出给宿舍的入住学生的信息
	 * 
	 * @Version1.0 2009-3-18 上午01:56:15 李双江（paradise.lsj@gmail.com）创建
	 * @param dormitoryid
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public JSONArray listStudentInfoInSpecDorm(String dormitoryid) {
		List studentInfoList = studentService.getStudentInfoByDormitoryID(dormitoryid);
		List returnStuInfoList = new ArrayList();
		for (int i = 0; i < studentInfoList.size(); i++) {
			Object[] obj = (Object[]) studentInfoList.get(i);
			String[] AStudentInfoList = new String[obj.length];
			for (int k = 0; k < obj.length; k++) {
				// if (k == 9) {
				// String birthdaytime = (obj[k] + "").substring(0, 10);
				// log.info(birthdaytime);
				// AStudentInfoList[k] = birthdaytime + "";
				// }
				AStudentInfoList[k] = (obj[k] + "");
			}
			returnStuInfoList.add(AStudentInfoList);
		}

		if (returnStuInfoList != null && returnStuInfoList.size() > 0) {
			JSONArray stulist = JSONArray.fromObject(returnStuInfoList);
			return stulist;
		}
		return null;
	}
}
